package com.ruoyi.voteRecord.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.voteRecord.dao.VoteWorksRecordDao;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.voteRecord.domain.VoteRecord;
import com.ruoyi.voteRecord.service.IVoteRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 投票记录管理Controller
 * 
 * @author hyl
 * @date 2025-06-21
 */
@RestController
@RequestMapping("/voteRecord/voteRecord")
public class VoteRecordController extends BaseController
{
    @Autowired
    private IVoteRecordService voteRecordService;

    /**
     * 查询投票记录管理列表
     */
    @PreAuthorize("@ss.hasPermi('voteRecord:voteRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(VoteWorksRecordDao voteWorksRecordDao)
    {
        startPage();
        List<VoteWorksRecordDao> list = voteRecordService.selectVoteRecordList(voteWorksRecordDao);
        return getDataTable(list);
    }

    /**
     * 导出投票记录管理列表
     */
//    @PreAuthorize("@ss.hasPermi('voteRecord:voteRecord:export')")
//    @Log(title = "投票记录管理", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, VoteRecord voteRecord)
//    {
//        List<VoteRecord> list = voteRecordService.selectVoteRecordList(voteRecord);
//        ExcelUtil<VoteRecord> util = new ExcelUtil<VoteRecord>(VoteRecord.class);
//        util.exportExcel(response, list, "投票记录管理数据");
//    }

    /**
     * 获取投票记录管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('voteRecord:voteRecord:query')")
    @GetMapping(value = "/{voteRecordId}")
    public AjaxResult getInfo(@PathVariable("voteRecordId") Long voteRecordId)
    {
        return success(voteRecordService.selectVoteRecordByVoteRecordId(voteRecordId));
    }

    /**
     * 新增投票记录管理
     */
    @PreAuthorize("@ss.hasPermi('voteRecord:voteRecord:add')")
    @Log(title = "投票记录管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VoteRecord voteRecord)
    {
        return toAjax(voteRecordService.insertVoteRecord(voteRecord));
    }

    /**
     * 修改投票记录管理
     */
    @PreAuthorize("@ss.hasPermi('voteRecord:voteRecord:edit')")
    @Log(title = "投票记录管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VoteRecord voteRecord)
    {
        return toAjax(voteRecordService.updateVoteRecord(voteRecord));
    }

    /**
     * 删除投票记录管理
     */
    @PreAuthorize("@ss.hasPermi('voteRecord:voteRecord:remove')")
    @Log(title = "投票记录管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{voteRecordIds}")
    public AjaxResult remove(@PathVariable Long[] voteRecordIds)
    {
        return toAjax(voteRecordService.deleteVoteRecordByVoteRecordIds(voteRecordIds));
    }
}
